<!doctype html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="icon" href="static/images/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
    <link rel="icon" href="static/images/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
    <link rel="stylesheet" href="lib/bootstrap-icons/font/bootstrap-icons.css">
    <link rel="stylesheet" href="static/css/bootstrap.min.css">
    <link rel="stylesheet" href="static/css/bootstrap-admin.min.css">
    <title>bootstrap-admin</title>
</head>
<body>

<div class="bg-light min-vh-100">
    <div class="min-vh-100 container d-flex justify-content-center align-items-center">
        <div class="card shadow border-0 bg-white my-3" style="width: 30rem;">
            <div class="card-header bg-white border-bottom p-3 text-center">
                <a href="index.html" class="h3  fs-4 text-muted text-decoration-none">
                    xx后台管理系统
                </a>
            </div>
            <div class="card-body">
                <form id="form" class="form">
                    <div class="mb-3">
                        <label for="username" class="form-label">账号</label>
                        <input type="text" class="form-control" id="username" name="username" placeholder="邮箱/用户名/手机号">
                    </div>
                    <div class="mb-3">
                        <label for="password" class="form-label">密码</label>
                        <input type="password" class="form-control" id="password" name="password"
                               placeholder="请输入密码">
                    </div>

                    <div class="mb-3">
                        <label for="captcha" class="form-label">验证码</label>
                        <div class="input-group mb-3">
                            <input type="text" class="form-control" id="captcha" name="captcha"
                                   placeholder="请输入验证码">
                            <img style="cursor: pointer" src="static/images/captcha.png"
                                 title="点击刷新"
                                 class="captcha-img"
                                 height="38"/>
                        </div>
                    </div>
                    <div class="mb-3 form-check">
                        <input type="checkbox" class="form-check-input" id="exampleCheck1" name="remember"
                               value="1">
                        <label class="form-check-label" for="exampleCheck1">记住我</label>
                    </div>

                    <div class="d-flex justify-content-between align-items-end">
                        <button id="login-btn" type="submit" class="btn btn-success">登录</button>
                        <div>
                            <span class="text-muted">没有帐号？ 点此</span>
                            <a href="javascript:" class="text-decoration-none text-dark">注册</a>
                        </div>
                    </div>
                </form>
            </div>

            <div class="card-footer bg-white">
                <div class="text-center py-2 my-2">
                    <span class="text-muted">继续即代表同意</span>
                    <a href="javascript:" class="text-decoration-none">《隐私政策》</a>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="static/js/bootstrap.bundle.min.js"></script>
<script src="src/bootstrap-admin.js"></script>

<script src="lib/jquery/dist/jquery.min.js"></script>
<script src="lib/formvalidation/js/formValidation.js"></script>
<script src="lib/formvalidation/js/framework/bootstrap.js"></script>
<script src="lib/formvalidation/js/language/zh_CN.js"></script>
<script>
    //前端表单验证
    $('#form').formValidation({
        fields: {
            username: {
                validators: {
                    notEmpty: true,
                }
            },
            password: {
                validators: {
                    notEmpty: true,
                }
            },
            captcha: {
                validators: {
                    notEmpty: true,
                }
            }
        }
    }).on('success.form.fv', function (e) {
        //阻止表单提交
        e.preventDefault();
        //得到表单对象
        let $form = $(e.target);
        let data = $form.serialize();

        alert('表单验证通过,即将发起ajax');
        //得到序列化数据
        $.ajax({
            url: "/login.php",
            method: 'POST',
            data
        }).then(function (res) {
            if (res.code === 200) {
                //登录成功
            } else {
                //登录失败
            }
        });
    });
</script>
</body>
</html>